
<template>
  <div class="container">
    <error-tip v-if='errorCode' :data='errorCode' />
    <card-list v-if='!errorCode' :data='dayData' />
    <card-item v-if='!errorCode' :data='dayData' />
  </div>
</template>
<script>
import { onMounted, computed } from 'vue'
import { useStore } from 'vuex'
import loadData from '@/server/index.js'
import { getNowDate } from '@/library/utils.js'
import ErrorTip from '@/components/error/index.vue'
import CardList from '@/components/daypage/list.vue'
import CardItem from '@/components/daypage/item.vue'
export default {
  name: 'daypage',
  components: {
    ErrorTip,
    CardList,
    CardItem
  },
  setup() {
    const store = useStore()
    onMounted(() => {
      if (store.state.searchText) {
        loadData(store, 'day', store.state.searchText)
      } else {
        loadData(store, 'day', getNowDate('day'))
      }
    })
    return {
      dayData: computed(() => store.state.dayData),
      errorCode: computed(() => store.state.errorCode)
    }
  }
}
</script>
<style lang="less" scoped>
.container {
  position: fixed;
  top: 78px;
  bottom: 47px;
  left: 0;
  width: 100%;
  overflow-y: auto;
}
.container::-webkit-scrollbar {
  width: 0;
}
</style>
